package script.functions

import com.tang.script.functions.ScriptFunction

@ScriptFunction(functionName = "包含")
static def like(var1, var2) {
    if (Objects.isNull(var2) || var2 == '') {
        return var1 + " is not null"
    }

    try {
        if (var2 instanceof String) {
            var2 += ""
            if (var2.charAt(0) == "'") {
                var2 = var2.substring(1)
            }
            if (var2.endsWith("'")) {
                var2 = var2.substring(0, var2.length() - 1)
            }
        }
    } catch (Exception e) {}
    return var1 + " like '%" + var2 + "%'"
}